package com.trover.myapplication.ui.home

import com.trover.myapplication.core.http.BaseRepository
import com.trover.myapplication.core.http.RetrofitClientFactory
import com.trover.myapplication.core.http.apimodel.Result
import com.trover.myapplication.entity.PlanEntity

class HomeRepository : BaseRepository() {

    suspend fun getPlans(
        inspectorId: String,
        limit: Int,
        offset: Int
    ): Result<PlanEntity> {
        return safeApiCall(call = { requestGetPlans(inspectorId, limit, offset) }, errorMsg = "")
    }

    private suspend fun requestGetPlans(
        inspectorId: String,
        limit: Int,
        offset: Int
    ): Result<PlanEntity> {
        val response = RetrofitClientFactory.service.getPlan(inspectorId, limit, offset, false)
        return Result.Success(response)
    }
}